#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QCloseEvent>
#include <QEvent>
#include <QString>
#include <QSettings>
#include <QMessageBox>
#include <QDir>
#include <QFileInfoList>
#include <QLibrary>
#include <QPluginLoader>
#include <QDebug>
#include <QFileDialog>
#include <QLabel>
#include <QGraphicsScene>
#include <QPushButton>
#include <QGraphicsProxyWidget>
#include <QTranslator>
#include <QThread>
#include <QThreadPool>
#include <QMutex>
#include <QWaitCondition>

#include "cvplugininterface.h"



QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *evnet);
    void changeEvent(QEvent *event);

private slots:
    void onPluginActionTriggered(bool b);
    void onLanguageActionTriggered(bool b);
    void onThemeActionTriggered(bool b);
    void onCurrentPluginUpdateNeeded(void);
    void onCurrentPluginErrorMessage(QString msg);
    void onCurrentPluginInfoMessage(QString msg);

    void on_actionAboutQt_triggered(void);
    void on_actionExit_triggered(void);
    void on_actionOpenImage_triggered(void);
    void on_viewOriginalCheck_toggled(bool checked);
    void on_actionSaveImage_triggered(void);
    void on_action_Camera_triggered(void);

private:
    Ui::MainWindow *ui;

    void loadSettings(void);
    void saveSettings(void);

    QString currentThemeFile;
    QString currentLanguageFile;
    QString currentPluginFile;

    void populatePluginsMenu(void);
    void populateLanguageMenu(void);
    void populateThemeMenu(void);


    QPointer<QPluginLoader> currentPlugin;
    QPointer<QWidget> currentPluginGui;
    QGraphicsScene scene;
    QTranslator translator;
    QGraphicsPixmapItem originalPixmap, processedPixmap;
    QImage originalImage, processedImage;

    cv::Mat originalMat, processedMat;
};
#endif // MAINWINDOW_H
